<div class="dialog">
    <table>
        <tbody>
                        
            <tr class="prop">
                <td valign="top" class="name"><g:message code="marketPriceActual.date" default="Date" />:</td>
                <td valign="top" class="value"><g:formatDate date="${marketPriceActualInstance?.date}" format="yyyy-MM-dd"/></td>
            
                <td valign="top" class="name"><g:message code="marketPriceActual.approved" default="Approved" />:</td>
                <td valign="top" class="value"><g:formatBoolean boolean="${marketPriceActualInstance?.approved}" /></td>

                <td valign="top" class="name">&nbsp;</td>
                <td valign="top" class="value">&nbsp;</td>
             </tr>
            
            <tr class="prop">
                <td valign="top" class="name"><g:message code="marketPriceActual.dateCreated" default="Date Created" />:</td>
                <td valign="top" class="value"><g:formatDate date="${marketPriceActualInstance?.dateCreated}" format="yyyy-MM-dd HH:mm:ss"/></td>
            
                <td valign="top" class="name"><g:message code="marketPriceActual.lastUpdated" default="Last Updated" />:</td>
                <td valign="top" class="value"><g:formatDate date="${marketPriceActualInstance?.lastUpdated}" format="yyyy-MM-dd HH:mm:ss"/></td>

                <td valign="top" class="name">&nbsp;</td>
                <td valign="top" class="value">&nbsp;</td>
             </tr>
            
        </tbody>
    </table>
</div>
<div class="list">
    <table>
        <thead>
            <tr>
                <th><g:message code="marketPriceActualDetail.serialNumber" default="Serial Number" /></th>
                <th><g:message code="marketPriceActualDetail.product" default="Product" /></th>
                <th class="number"><g:message code="marketPriceActualDetail.regionPrice" default="Region Price" /></th>
                <th><g:message code="marketPriceActualDetailDetail.serialNumber" default="Detail Serial Number" /></th>
                <th><g:message code="marketPriceActualDetailDetail.retailer" default="Retailer" /></th>
                <th class="number"><g:message code="marketPriceActualDetailDetail.lowPrice" default="Low Price" /></th>
                <th class="number"><g:message code="marketPriceActualDetailDetail.highPrice" default="High Price" /></th>
           </tr>
        </thead>
        <tbody>
        <g:each in="${marketPriceActualInstance?.details?.sort{it?.serialNumber}}" status="i" var="marketPriceActualDetailInstance">
            <g:set var="product" value="${fieldValue(bean: marketPriceActualDetailInstance, field: 'product')}" />
            <g:set var="rowspan" value="${marketPriceActualDetailInstance?.details?.size()}"/>
            <g:set var="rowspan" value="${rowspan > 0 ? rowspan + 1 : 0}"/>
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td ${(rowspan > 0)?('rowspan="'+rowspan+'"'):('') }>
                    ${fieldValue(bean: marketPriceActualDetailInstance, field: "serialNumber")}
                </td>
                <td ${(rowspan > 0)?('rowspan="'+rowspan+'"'):('') }>
                    ${product}
                </td>
                <td class="number" ${(rowspan > 0)?('rowspan="'+rowspan+'"'):('') }>
                    ${formatNumber(number : marketPriceActualDetailInstance.regionPrice, format : '###,##0.00')}
                </td>
            </tr>
            <g:if test="${rowspan > 0}">
            <g:each in="${marketPriceActualDetailInstance?.details?.sort{it?.serialNumber}}" status="j" var="marketPriceActualDetailDetailInstance">
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <!--serialNumber-->
                <td>
                    ${fieldValue(bean: marketPriceActualDetailDetailInstance, field: "serialNumber")}
                </td>
                <!--retailer-->
                <td>
                    ${marketPriceActualDetailDetailInstance?.retailer}
                </td>
                <!--lowPrice-->
                <td class="number">
                    ${formatNumber(number : marketPriceActualDetailDetailInstance.lowPrice, format : '###,##0.00')}
                </td>
                <!--highPrice-->
                <td class="number">
                    ${formatNumber(number : marketPriceActualDetailDetailInstance.highPrice, format : '###,##0.00')}
                </td>
            </tr>
            </g:each>
            </g:if>
        </g:each>
        </tbody>
    </table>
</div>

